home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / misc / emu / ATUtilities.lha / ATUtilities / BASIC / STRGAD.BAS < prev    next >
BASIC Source File  |  2000-09-26  |  2KB  |  126 lines

  1. screen 12
  2.  
  3. call DrawNBorder(10,10,40,1)
  4. locate 11,12
  5.  
  6. gad.id=0
  7. gad.text$(gad.id)="Dies ist ein Testtext"
  8. gad.x(gad.id)=10
  9. gad.y(gad.id)=10
  10. gad.w(gad.id)=40
  11. gad.strmax(gad.id)=37
  12.  
  13.  
  14. key 25,chr$(0,&H53)
  15. on key(12) gosub links
  16. on key(13) gosub rechts
  17. on key(25) gosub del
  18. key(12) on
  19. key(13) on
  20. key(25) on
  21. sp=len(gad.text$(gad.id))
  22. mx=gad.strmax(gad.id)
  23. cursor=sp
  24. undo$=gad.text$(gad.id)
  25. call Neu
  26. i$=inkey$
  27. call MouseDown
  28. while i$<>chr$(13) and mouse.button=0
  29.  if i$<>"" then
  30.   select case i$
  31.    case chr$(8)
  32.     if sp>0 and cursor>0 then
  33.      q$=gad.text$(gad.id)
  34.      gad.text$(gad.id)=left$(q$,cursor-1)+mid$(q$,cursor+1,sp-cursor)
  35.      cursor=cursor-1
  36.      sp=sp-1
  37.      call Neu
  38.     else
  39.      sound 2000,1
  40.     end if
  41.    case chr$(27)
  42.     gad.text$(gad.id)=undo$
  43.     sp=len(undo$)
  44.     call Neu
  45.    case else
  46.     if asc(i$)>30 then
  47.      if sp<mx then
  48.       q$=gad.text$(gad.id)
  49.       gad.text$(gad.id)=left$(q$,cursor)+i$+mid$(q$,cursor+1,sp-cursor)
  50.       sp=sp+1 : cursor=cursor+1
  51.       call Neu
  52.      else
  53.       sound 2000,1
  54.      end if
  55.     else
  56.      sound 2000,1
  57.     end if
  58.   end select
  59.  end if
  60.  i$=inkey$
  61.  call MouseDown
  62. wend
  63. cursor=33333
  64. call Neu
  65. key(12) off
  66. key(13) off
  67. key(25) off
  68.  
  69. end
  70.  
  71.  
  72. links:
  73.  if cursor>0 then
  74.   cursor=cursor-1
  75.   call Neu
  76.  end if
  77. return
  78.  
  79. rechts:
  80.  if cursor<sp then
  81.   cursor=cursor+1
  82.   call Neu
  83.  end if
  84. return
  85.  
  86. del:
  87.  if cursor<sp and sp>0 then
  88.   q$=gad.text$(gad.id)
  89.   gad.text$(gad.id)=left$(q$,cursor)+mid$(q$,cursor+2,sp-cursor)
  90.   sp=sp-1
  91.   if cursor>sp then cursor=cursor-1
  92.   call Neu
  93.  end if
  94. return
  95.  
  96. sub Neu shared
  97.  call MouseOff
  98.  locate gad.y(gad.id)+1,gad.x(gad.id)+2
  99.  color 15
  100.  z$=gad.text$(gad.id)+string$(1+gad.strmax(gad.id)-len(gad.text$(gad.id))," ")
  101.  print z$;
  102.  if cursor<33333 then
  103.   color 14
  104.   locate gad.y(gad.id)+1,gad.x(gad.id)+2+cursor
  105.   z$=mid$(z$,cursor+1,1)
  106.   if z$=" " then z$="_"
  107.   print z$;
  108.  end if
  109.  call MouseOn
  110. end sub
  111.  
  112.  
  113. sub MouseOff static
  114. end sub
  115. sub MouseOn static
  116. end sub
  117. sub MouseDown static
  118. end sub
  119. sub DrawNBorder(x,y,w,h) static
  120.  x1=x*8-4
  121.  y1=y*16-8
  122.  x2=x1+(w*8)+8
  123.  y2=y1+(h*16)+16
  124.  line (x1,y1)-(x2,y2),15,b
  125. end sub
  126.